<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>  案件管理
                        </li>
                    </ol>
                </div>
            </div>
                <form action="/admin_qycase" method="post">
                <div class="row">
                <div class="col-md-4">
                    <a class="btn btn-success" id="default">重置</a>
                    <!--<select name="policyno">
                    <option>保单号</option>
                    <?foreach($tPolicy as $tRow){?>
                    <option <?if($pPolicyno == $tRow['policyno']){echo 'selected';}?>><?=$tRow['policyno']?></option>
                    <?}?>
                </select>-->
                </div>
                <div class="col-md-4">
                    <!--<select name="status">
                    <option value="">赔付状态</option>
                    <option value="1" <?if($pStatus==1){echo 'selected';}?>>审核中（速赔宝）</option>
                    <option value="2" <?if($pStatus==2){echo 'selected';}?>>有问题（初审）</option>
                    <option value="3" <?if($pStatus==3){echo 'selected';}?>>预结案</option>
                    <option value="4" <?if($pStatus==4){echo 'selected';}?>>已结案</option>
                    <option value="5" <?if($pStatus==5){echo 'selected';}?>>有问题（临审）</option>
                    <option value="6" <?if($pStatus==6){echo 'selected';}?>>审核中（华道）</option>
                </select>-->
                </div>
                <div class="col-md-4">
                    <!--<select name="sourceflag">
                    <option value="">审核来源</option>
                    <option value="2" <?if($pSourceflag==2){echo 'selected';}?>>线上</option>
                    <option value="1" <?if($pSourceflag==1){echo 'selected';}?>>线下</option>
                </select>-->
                </div>
            </div>
            <div class="row" style="margin-top:6px;">
                <div class="form-group col-md-4">
                            <div class="input-group date form_date" data-date="<?=date("Y-m-d",time())?>" data-date-format="yyyy-mm-dd" data-link-field="started" id="datetimeStart">
                                <input class="form-control" size="16" type="text" value="<?=$pStarted?>" readonly placeholder="选择开始日期">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                            </div>
                            <input type="hidden" id="started" value="" name="started" /><br/>
                    </div>
                <div class="form-group col-md-4">
                            <div class="input-group date form_date" data-date="<?=date("Y-m-d",time())?>" data-date-format="yyyy-mm-dd" data-link-field="updated" id="datetimeEnd">
                                <input class="form-control" size="16" type="text" value="<?=$pUpdated?>" readonly placeholder="选择结束日期">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                            </div>
                            <input type="hidden" id="updated" value="" name="updated" /><br/>
                    </div><button type="button" id="search1" class="btn btn-success">确定</button>
                 <div class="col-md-4" style="position:relative">
                 <button type="button" class="btn btn-default" id="search" style="float:right;right:15px;position:absolute"><i class="fa fa-search"></i></button>
                 <input type="text" placeholder="请输入被保人姓名关键字" value="<?=$pKey?>" name="key" class="form-controll" style="float:right;width:335px;height:33px;">
                 </div>
            </div>
            <div class="row">
                 <a href="/admin_qycase/download?id=<?=$tId?>" class="btn btn-success" id="allDownload" style="margin-left:15px;">全部下载</a>
            </div>
            <div class="panel-body text-center">
                <table class="table table-hover" id="sample-table-1">
                    <thead>
                        <tr>
                            <td>CaseID
							<select name="caseID">
							<option value="">请选择</option>
							<option value="1" <?if($tcaseID == 1){echo 'selected';}?>>升序</option>
							<option value="2"<?if($tcaseID == 2){echo 'selected';}?>>降序</option>
							</select>
							</td>
                            <td>被保人姓名</td>
                            <td>证件类型</td>
                            <td>证件号码</td>
                            <td>属组</td>
                            <td>保单号
                    <select name="policyno">
                    <option value="">请选择</option>
                    <?foreach($tPolicy as $tRow){?>
                    <option <?if($pPolicyno == $tRow['policyno']){echo 'selected';}?>><?=$tRow['policyno']?></option>
                    <?}?>
                </select>
							</td>
                            <td>申请时间
							<select name="sqtime">
							<option value="">请选择</option>
							<option value="1"<?if($tsqtime == 1){echo 'selected';}?>>升序</option>
							<option value="2"<?if($tsqtime == 2){echo 'selected';}?>>降序</option>
							</select>
							</td>
                            <td>赔付状态
                    <select name="status">
                    <option value="">请选择</option>
                    <option value="1" <?if($pStatus==1){echo 'selected';}?>>审核中（速赔宝）</option>
                    <option value="2" <?if($pStatus==2){echo 'selected';}?>>有问题（初审）</option>
                    <option value="3" <?if($pStatus==3){echo 'selected';}?>>预结案</option>
                    <option value="4" <?if($pStatus==4){echo 'selected';}?>>已结案</option>
                    <option value="5" <?if($pStatus==5){echo 'selected';}?>>有问题（临审）</option>
                    <option value="6" <?if($pStatus==6){echo 'selected';}?>>审核中（华道）</option>
                </select>
							</td>
                            <td>最新状态时间
							<select name="zxtime">
							<option value="">请选择</option>
							<option value="1"<?if($tzxtime == 1){echo 'selected';}?>>升序</option>
							<option value="2"<?if($tzxtime == 2){echo 'selected';}?>>降序</option>
							</select>
							</td>
                            <td>审核来源
                    <select name="sourceflag">
                    <option value="">请选择</option>
                    <option value="2" <?if($pSourceflag==2){echo 'selected';}?>>线上</option>
                    <option value="1" <?if($pSourceflag==1){echo 'selected';}?>>线下</option>
                </select>
							</td>
                            <td>分案号</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <?foreach($tDatas as $tRow){?>
                    <tr>
                        <td><?=$tRow['case_id']?></td>
                        <td><?=$tRow['username']?></td>
                        <td><?=$tRow['crittype_info']?></td>
                        <td><?=$tRow['critcode']?></td>
                        <td><?=$tRow['policygroupremak']?></td>
                        <td><?=$tRow['policyno']?></td>
                        <td><?=date('Y-m-d H:i:s',$tRow['upload_time'])?></td>
                        <td><?echo$tStatus[$tRow['status']];
    if($tRow['status'] == 4){
        switch($tRow['is_dishonor']){
            case '2': echo '(拒付)';break;
            case '1': echo '(已付)';break;
            case '0': echo '(撤单)';break;
        }
    }
?></td>
                        <td><?=date('Y-m-d H:i:s',$tRow['updated'])?></td>
                        <td><?if(empty($tRow['sourceflag'])){?>线上<?}else{?>线下<?}?></td>
                        <td><?=$tRow['hd_caseno']?></td>
                        <td>
                            <div class="visible-md visible-lg hidden-sm hidden-xs">
                                <a href="/admin_qycase/detail?case_id=<?=$tRow['case_id']?>" class="btn btn-green btn-xs tooltips" data-placement="top" data-original-title="查看详细" ><i class="fa fa-list"></i></a>
                                <a href="/admin_qycase/download?case_id=<?=$tRow['case_id']?>" class="btn btn-green btn-xs tooltips" data-placement="top" data-original-title"下载"><i class="fa fa-cloud-download"></i></a>
                            </div>

                            <div class="visible-xs visible-sm hidden-md hidden-lg">
                                <div class="btn-group">
                                    <a class="btn btn-green dropdown-toggle btn-sm" data-toggle="dropdown" href="#">
                                        <i class="fa fa-cog"></i> <span class="caret"></span>
                                    </a>
                                    <ul role="menu" class="dropdown-menu pull-right dropdown-dark">
                                        <li>
                                            <a role="menuitem" tabindex="-1" href="/admin_qycase/detail?case_id=<?=$tRow['case_id']?>">
                                                <i class="fa fa-share"></i>查看详细
                                            </a>
                                        </li>
                                    </ul>
                                    <a class="btn btn-green dropdown-toggle btn-sm" data-toggle="dropdown" href="#">
                                    <i class="fa fa-cog"></i><span class="creat"></span>
                                    </a>
                                    <ul role="menu" class="dropdown-menu pull-right dropdown-dark">
                                    <li>
                                        <a role="menuitem" tabindex="-1" href="/admin_qycase/download?case_id=<?=$tRow['case_id']?>">
                                        <i class="fa fa-share"></i>下载
                                        </a>
                                    </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
<?}?>
                </table>
<?=$tShow?>
            </div>
        </div>
            </form>
        <div class="subviews">
            <div class="subviews-container"></div>
        </div>
    </div>
    <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="/plugins/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script>
$('#datetimeStart').datetimepicker({
    language:  'zh-CN',
    format: "yyyy-mm-dd",
    autoclose: true,
    minView: "month",
    maxView: "decade",
    todayBtn: true,
    pickerPosition: "bottom-left"
}).on("click",function(ev){
    $("#datetimeStart").datetimepicker("setEndDate", $("#updated").val());
});
$('#datetimeEnd').datetimepicker({
    language:'zh-CN',
    format: "yyyy-mm-dd",
    autoclose: true,
    minView: "month",
    maxView: "decade",
    todayBtn: true,
    maxDate:$('#started').val(),
    pickerPosition: "bottom-left"
}).on("click",function(ev){
        $("#datetimeEnd").datetimepicker("setStartDate",$("#started").val());
});
$('#search1').click(function(){
        var startDay = $.myTime.DateToUnix($('#started').val());
        var endDay = $.myTime.DateToUnix($('#updated').val());
        var d = endDay-startDay;
        var e = 30*3600*24;
        var isTrue = Math.abs(d-e);
        if(d-e === isTrue){
            alert('选择的开始日期和结束日期间隔超过了30天，请重新选择！');return;
        }
$('form').submit();
});
$('#search').click(function(){
	$('form').submit();		
});
$('#default').click(function(){
    window.location.href = "/admin_qycase";
});
$('select').on('change',function(){
	$('#search').trigger('click');
});
(function($){
    $.extend({
        myTime:{
            /**
            *当前时间戳
            *@return<int> unix时间戳(秒)
            */
            CurTime:function(){
                return Date.parse(new Date())/1000;
            },
            /**
            * 日期转换为时间戳
            * @param <string> 2014-01-01 20:20:20日期格式
            * @return <int> unix时间戳(秒)
            */
            DateToUnix:function(string){
                var f = string.split(' ',2);
                var d = (f[0] ? f[0] : '').split('-',3);
                var t = (f[1] ? f[1] : '').split(':',3);
                return (new Date(
                        parseInt(d[0],10) || null,
                        (parseInt(d[1],10) || 1) - 1,
                        parseInt(d[2],10) || null,
                        parseInt(t[0],10) || null,
                        parseInt(t[1],10) || null,
                        parseInt(t[2],10) || null
                    )).getTime()/1000;
            },
            /**
            *时间戳转换日期
            *@param <int> unixTime 待时间戳(秒)
            *@param <bool> isFull 反悔完整时间(Y-m-d或者Y-m-d H:i:s) 
            *@param <int> timeZone 时区
            */
            UnixToDate:function(unixTime,isFull,timeZone){
                if(typeof(timeZone) == 'number'){
                    unixTime = parseInt(unixTime) + parseInt(timeZone)*60*60;     
                }
                var time = new Date(unixTime * 1000);
                var ymdhis = "";
                ymdhis += time.getUTCFullYear() + "-";
                ymdhis += (time.getUTCMonth()+1) + "-";
                ymdhis += time.getUTCDate();
                if(isFull === true){
                    ymshis += "" + time.getUTCHours() + ":";
                    ymdhis += time.getUTCMinutes() + ":";
                    ymdhis += time.getUTCSeconds();
                }
                return ymdhis;
            }
                
        }    
    });
})(jQuery);

</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
